/**
 * Created by jocky on 15/09/2017.
 */
//绑定enter事件
$('body').bind('keyup', function (event) {
    if (event.keyCode == "13") {
        $("button[name=form-submit]").trigger("click");
    }
});


/**
 * 错误提示框
 *
 * @param msg
 * @param close
 */
function setNotify(msg, close) {
    if (close) {
        PNotify.removeAll();
    }

    new PNotify({
        title: '提示',
        text: msg,
        type: 'error',
        styling: 'bootstrap3',
        delay: 5000
    });
}

/**
 * 获取新的验证码
 *
 * @param type
 */
function refreshCaptcha(type) {
    var url;
    if (type == 1) {
        url = '/reg/captcha';
    } else if (type == 2) {
        url = '/login/captcha';
    } else {
        url = '/password/captcha';
    }
    $.getJSON(url, {refresh: 1}, function (json) {
        $("#captchaImg" + type)[0].src = json.url;
    });
}